let token = JSON.parse(localStorage.getItem('token'))

// total文章的总数
getIdAticle(token,{pagenum:1,pagesize:9999},function(res){
  let total = res.total < 999999 ? res.total : res.total + '+'

  // 日新增文章数dayAddTotal
  let new_date = new Date()
  let Y = new_date.getFullYear()
  let M = new_date.getMonth() + 1
  M = M < 10 ?  '0'+M : M;
  let D = new_date.getDate()
  D = D < 10 ?  '0'+D : D;
  new_date = Y + "-" + M +"-"+ D
  let dayAddTotal = 0
  res.data.forEach(item=>{
    let pub_date = item.pub_date.substring(0,10)
      if(pub_date === new_date){
        dayAddTotal++
      }
  })

  let data = {
    total:total,
    dayAddTotal:dayAddTotal
  }
  let htmlStr = template('totalNum',data)
  $('.total-num').html(htmlStr)


 
  getAticList(token,function(res){
    let arrList = []
    let arrName = []
    res.data.forEach(item=>{
      let categoryName = item.name
      let cate_id = item.Id
      getIdAticle(token,{pagenum:1,pagesize:99999,cate_id:cate_id},function(res){
        console.log(res);
        let categoryList = {
          value:res.total,
          name:categoryName
        }
        arrList.push(categoryList)
        arrName.push(categoryName)
        // console.log(arrList);
        // console.log(arrName);
        render(arrList,arrName)
      })
    })
   
  })

})
